﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace projekt_planet_express_doerr
{
    class GUI : Microsoft.Xna.Framework.DrawableGameComponent
    {

        //Yellow Buttons
        public Texture2D YelArrowLeftTex, YelArrowRightTex;
        Rectangle YelArrowLeftRec, YelArrowRightRec;

        //Green Buttons
        public Texture2D GreArrowLeftTex, GreArrowRightTex;
        Rectangle GreArrowLeftRec, GreArrowRightRec;

        public GUI(Game game)
            : base(game)
        {
            YelArrowLeftRec = new Rectangle(25, 500, 75, 75);
            YelArrowRightRec = new Rectangle(100, 500, 75, 78);

            GreArrowLeftRec = new Rectangle(25, 600, 75, 75);
            GreArrowRightRec = new Rectangle(100, 596, 75, 78);
        }

        protected override void LoadContent()
        {
            YelArrowLeftTex = Game.Content.Load<Texture2D>("gelbLinks");
            YelArrowRightTex = Game.Content.Load<Texture2D>("gelbRechts");

            GreArrowLeftTex = Game.Content.Load<Texture2D>("gruenLinks");
            GreArrowRightTex = Game.Content.Load<Texture2D>("gruenRechts");

            base.LoadContent();
        }

        public override void Update(GameTime gameTime)
        {
            MouseState mouseState = Mouse.GetState();
            if ((mouseState.X > 25 && mouseState.X < 90) && (mouseState.Y > 520 && mouseState.Y < 550))
            {
                if (mouseState.LeftButton == ButtonState.Pressed)
                {
                    Game1.instance.backGroundState = Game1.bGState.bx;
                }
            }

            if ((mouseState.X > 120 && mouseState.X < 185) && (mouseState.Y > 520 && mouseState.Y < 550))
            {
                
                if (mouseState.LeftButton == ButtonState.Pressed)
                {
                    Game1.instance.backGroundState = Game1.bGState.sp;
                }
            }

            if ((mouseState.X > 25 && mouseState.X < 90) && (mouseState.Y > 620 && mouseState.Y < 650))
            {
                if (mouseState.LeftButton == ButtonState.Pressed)
                {
                    Game1.instance.arrow.lookAt = Arrow.LookAtState.metA;
                }
            }

            if ((mouseState.X > 120 && mouseState.X < 185) && (mouseState.Y > 620 && mouseState.Y < 650))
            {
                if (mouseState.LeftButton == ButtonState.Pressed)
                {
                    Game1.instance.arrow.lookAt = Arrow.LookAtState.metB;
                }
            }

            base.Update(gameTime);
        }

        internal void drawGUI(SpriteBatch spriteBatch, GameTime gameTime)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(YelArrowLeftTex, YelArrowLeftRec, Color.White);
            spriteBatch.Draw(YelArrowRightTex, YelArrowRightRec, Color.White);

            spriteBatch.Draw(GreArrowLeftTex, GreArrowLeftRec, Color.White);
            spriteBatch.Draw(GreArrowRightTex, GreArrowRightRec, Color.White);
            spriteBatch.End();
        }
    }
}
